package app.r_teenus.frontend.controller;


import java.util.Collection;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import app.r_teenus.backend.dao.EmployeeDao;
import app.r_teenus.backend.model.Employee;
import app.r_teenus.backend.model.Enterprise;



@Controller
public class EmployeeController {

    final Logger logger = LoggerFactory.getLogger(EmployeeController.class);
    
    static final String SEARCH_VIEW_PATH_KEY = "/search";
    
    private static final String SEARCH_VIEW_KEY = "search.html";
    private static final String SEARCH_MODEL_KEY = "employees";

    @Autowired
    protected EmployeeDao employeeDao = null;

    /**
     * <p>Deletes a employee.</p>
     * 
     * <p>Expected HTTP POST and request '/enterprise/delete'.</p>
     */
    @RequestMapping(value="/employee/delete", method=RequestMethod.POST)
    public String delete(Enterprise enterprise) {
//        enterpriseDao.delete(enterprise);

        return SEARCH_VIEW_KEY;
    }

    /**
     * <p>Searches for all enterprises and returns them in a 
     * <code>Collection</code>.</p>
     * 
     * <p>Expected HTTP GET and request '/enterprise/search'.</p>
     */
    @RequestMapping(value="/employee/search", method=RequestMethod.GET)
    public @ModelAttribute(SEARCH_MODEL_KEY) Collection<Employee> search() {
        return employeeDao.findEmployees();
    }

}
